package DBTasks;

import java.sql.SQLException;
import java.sql.Statement;
import java.sql.ResultSet;

import javax.swing.JComboBox;

public class BreedList extends DBTask{

	private static ResultSet rsDog;
	private static ResultSet rsCat;
	private static JComboBox catList;
	private static JComboBox dogList;

	@SuppressWarnings("static-access")
	public static JComboBox[] listBreeds() {
		
		Statement dogStatement;
		
		catList = new JComboBox();
	    catList.setSize(catList.getPreferredSize().width, catList.getPreferredSize().height);
	    dogList = new JComboBox();
	    dogList.setSize(catList.WIDTH, catList.HEIGHT);
		
		try {
			
			dogStatement = con.createStatement();
			rsDog = dogStatement.executeQuery("select Breed from Dog_Breed");
		    
		    Statement catStatement = con.createStatement();
		    rsCat = catStatement.executeQuery("select Breed from Cat_Breed");
		    
		    while(rsDog.next()){
				dogList.addItem(rsDog.getString(1));
			}
			
			while(rsCat.next()){
				catList.addItem(rsCat.getString(1));
			}
			
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	    	
		JComboBox[] boxes = {dogList, catList};
		return boxes;
		
	}

}
